from pythonds.basic.stack import Stack


def parChecker(symbolString):
    stack = Stack()
    balanced = True
    index = 0
    while index < len(symbolString) and balanced:
        symbol = symbolString[index]
        if symbol == '(':
            stack.push(symbol)
        else:
            if stack.isEmpty():
                balanced = False  # 只有一个右括号但是没有入栈
            else:
                stack.pop()  # 移除之前的一个左括号
        index += 1
    if balanced and stack.isEmpty():
        return True
    else:
        return False


print(parChecker('('))  # False
print(parChecker('(())'))  # True
print(parChecker(''))  #True
